﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>新增分类</title>
    <link href="~/Areas/AdminMrg/Content/adminCss/dialog.css" rel="stylesheet" />
    <script src="~/CommonResource/Js/jquery-1.8.3.min.js"></script>
    <!--弹出层-->
    <script src="~/CommonResource/artDialog/jquery.artDialog.source.js?skin=blue"></script>
    <script src="~/CommonResource/artDialog/plugins/iframeTools.source.js"></script>
    <script type="text/javascript">
        $(function () {
            art.dialog.data('ReturnParentId', null);

            $("#cancleBtn").click(function () {
                art.dialog.data('ReturnParentId', null);
                art.dialog.close();
            });

            $("#okBtn").click(function () {
                var name = $("#typeName").val().trim();
                var parentId = $("#parentTypeId").val();
                if (name == "") {
                    alert("请输入分类名");
                    return false;
                }
                if (parentId == "") {
                    alert("请选择分类");
                    return false;
                }
                //添加/编辑
                var params = {};
                var currentId = '@ViewBag.cId';
                var action="AddProductType";

                if (currentId != "") {
                    //编辑
                    action = "EditProductType";
                    params.currentId = currentId;
                }
                params.action = action;
                params.name = name;
                params.parentId = parentId;
                $.ajax({
                    url: "/Areas/AdminMrg/Ashx/MProduct.ashx",
                    data: params,
                    type: "POST",
                    dataType: "json",
                    success: function (msg) {
                        if (msg.OperateResult == "操作成功") {
                            alert("操作成功");
                            art.dialog.data('ReturnParentId', parentId);
                            art.dialog.close();
                        }
                    },
                    error: function (e) {
                        alert("操作失败");
                    }
                });
            });
        });
    </script>
</head>
<body>
    <div class="dialogBox">
        <div class="textBox">
            <div class="title">分类名：</div>
            <input type="text" id="typeName" />
        </div>
        <div class="textBox">
            <div class="title">选择分类：</div>
            <div class="typeListBox">
                @Html.Partial("MProductSelectType")
            </div>
        </div>
        <div class="textBox">
            <div class="title">选择结果：</div>
            <input type="text" id="parentTypeName" readonly="readonly" disabled="disabled" />
            <input type="hidden" id="parentTypeId" />
        </div>
    </div>
    <div class="bottomBtn">
        <a id="okBtn">确认</a>
        <a id="cancleBtn">取消</a>
    </div>
</body>
</html>
